﻿using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using System.IO;

public class CreateAssetBundle
{

    [MenuItem("Bulid/BUild AssetBundles")]//编辑器菜单路径 打包
    static void BulidAllAssetBundle()
    {
        if (!Directory.Exists("bundles"))
        {
            Directory.CreateDirectory("bundles");
        }

#if UNITY_ANDROID//安卓端
        Debug.Log("安卓平台打包成功");
        BulidPipeline.BulidAssetBundles(Application.streamingAssetsPath,
        BulidAssetBundleOptions.UncompressedAssetBundle,
        BulidTarget.Android);
#elif UNITY_IPHONE//IOS
         Debug.Log("IOS平台打包成功");
        BulidPipeline.BulidAssetBundles(Application.streamingAssetsPath,
        BulidAssetBundleOptions.UncompressedAssetBundle,
        BulidTarget.iOS);
#elif UNITY_STANDALONE_WIN||UNITY_EDITOR//PC或则编辑器
        Debug.Log("PC平台打包成功");
        BuildPipeline.BuildAssetBundles("bundles",
            BuildAssetBundleOptions.UncompressedAssetBundle,
            BuildTarget.StandaloneWindows);
#endif
    }
}
